<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        
        <title><?php echo config_item('site_title'); ?></title>
		
		<script src="<?php echo base_url(); ?>application/assets/js/jquery.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/jquery-1.6.4.min.js"></script>		
		<script src="<?php echo base_url(); ?>application/jquery/jquery-ui-1.8.13.custom.min.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/bootstrap-dropdown.js"></script>
		<link href="<?php echo base_url(); ?>application/jquery/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet">
		
		<script src="<?php echo base_url(); ?>application/assets/jquerytree/jquery.treeview.js"></script>
		<link rel="stylesheet" href="<?php echo base_url(); ?>application/assets/jquerytree/jquery.treeview.css" />
		
		<link href="<?php echo base_url(); ?>application/assets/css/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
				padding-top: 60px;
				padding-bottom: 40px;
				background-color: #f5f5f5;
			  }
			  .leftpanel {
				width:100%;				
			  }
			  .leftpanel div {
				height:400px;
			  }
			  .filetree {
				font-size:9pt;
				
			  }
			  #footer {
			   position:fixed;
			   left:0px;
			   bottom:-20px;
			   height:30px;
			   width:100%;
			}
			li {
				line-height: 12px;
			}
			.alert-success {
				color: #5C5C5C;
				background-color: #EBEEE7;
				border-color: #d6e9c6;
				box-shadow:1px 1px 1px #90A377;
				}
        </style>
        <link href="<?php echo base_url(); ?>application/assets/css/bootstrap-responsive.css" rel="stylesheet">

        <script type="text/javascript">
			$(document).ready(function() {
				$( "#leftpanel" ).accordion();
				initTrees();
				RefreshArticles();
            });
			
			function initTrees() {
				var baseurl = $("#baseurl").val();
				//alert(baseurl  + "Categories/getCategories");
				
				$("#categories_tree").treeview({
					url: baseurl  + "Categories/getCategories"
				});
			}

			function RefreshArticles() {
				var baseurl = $("#baseurl").val();

				$.ajax({         
					url: baseurl + "Articles/getArticles", 
					type: "POST",
					dataType: "json",					        
					success: function(data) { 
						//alert('received data' + data.articles);
						if(data.articles.length > 0) {
							for(i = 0; i < data.articles.length; i++) {
							$("#articles").append("<div class=\"alert alert-success\">" + (data.articles[i].article) 
								+ "<hr><div><a href=\"Home\">Open</a> &nbsp; &nbsp; <a href=\"Home\">Delete</a><span class=\"muted pull-right\">March 4th 2013 | By Jayesh</span></div></div>");
							}
						} else {
							$("#articles").append("<div class=\"text-error\">No articles found !</div>");
						}
					},
					error:function (xhr, ajaxOptions, thrownError){
						alert('Error while getting articles !');
					}
				});
			}

        </script>
	</head>
	<body>
		<?php
			echo getTopNav();
		?>
		
		<div class="container">
                <div class="well">
										
					<?php echo anchor('Articles/createNew', 'Create New', 'title="Create New Post", class="btn btn-success btn-small"'); ?>

				</div>
		
				<div class="row-fluid">
                    <!--
                    <div class="span3">
						<div id="leftpanel" class="leftpanel">
						  <h3 style="padding-left:30px;"><i class="icon-list-alt"></i>&nbsp;Notes</h3>
						  <div>
							<ul id="categories_tree" class="afiletree treeview-famfamfam">
								
							</ul>
							
						  </div>
						  <h3 style="padding-left:30px;">Section 2</h3>
						  <div>
							<p>
							Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
							purus. 
							</p>
						  </div>
						 
						</div>
					</div>
				-->
					<div class="span12">
                       <div id="articles" ></div>
                    </div><!--/span-->
                </div><!--/row-->

                <!-- Include footer -->
                <?php include 'footer.php' ?>
            </div>
			
			<!-- Hidden variables -->
			<input type="hidden" id="baseurl" name="baseurl" value="<?php echo base_url(); ?>">
	</body>
	
	<!-- Placed at the end of the document so the pages load faster -->
    
			
</html>